package xyz.schwi.cels.view;

import xyz.schwi.cels.dao.impl.BaseDaoImpl;
import xyz.schwi.cels.entity.Word;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author schwi
 * @date 2021/9/29 0029  14:46
 */
public class Menu {
    public void title() {
        System.err.println("作者：Schwi");
        System.err.println("---------------------------");
    }

    public void mainMenu() {
        System.out.println("# 1.    浏览基库[单词和词汇]");
        System.out.println("# 2.    做游戏学习单词[随机性]");
        System.out.println("# 3.    测试自己的水平[随机性]");
        System.out.println("# 4.    生词表");
        System.out.println("# 0.    退出");
        System.out.println("---------------------------");
    }

    public void firstMenu() {
        System.out.println("    -> 1.    浏览单词");
        System.out.println("    -> 2.    浏览词汇");
        System.out.println("    -> 0.    返回上一级");
        System.out.println("---------------------------");
    }

    public void secondMenu() {
        System.out.println("    -> 1.    提示英文，回答中文");
        System.out.println("    -> 2.    提示中文，回答英文");
        System.out.println("    -> 0.    返回上一级");
        System.out.println("---------------------------");
    }

    public void thirdMenu() {
        System.out.println("测试自己的水平[随机性]");
        System.out.println("---------------------------");
    }

    public void forthMenu() {
        System.out.println("生词表");
        System.out.println("    -> 1.    浏览生词表");
        System.out.println("    -> 2.    测试生词表");
        System.out.println("    -> 0.    返回上一级");
        System.out.println("---------------------------");
    }

    public void characterMenu() {
        try {
            Map<Character, List<Word>> wordsMap = new BaseDaoImpl().getWordsMap("data\\w.dic");
            for (char i = 'A'; i <= 'Z'; i++) {
                System.out.print(i + "[" + (wordsMap.containsKey(i) ? wordsMap.get(i).size() : 0) + "]\t");
                if ((i - 64) % 5 == 0) {
                    System.out.println();
                }
            }
            System.out.println();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
